#include <vector>

using namespace std;

struct TreeNode
{
    int val;
    TreeNode * left;
    TreeNode * right;
    TreeNode() : val(0), left(nullptr), right(nullptr)
    {}
    TreeNode(int val) : val(val), left(nullptr), right(nullptr)
    {}
    TreeNode(int val, TreeNode * left, TreeNode * right) : val(val), left(left), right(right)
    {}
};


class Solution 
{
public:

    void recursion(TreeNode * cur, vector<int> & vec)
    {
        if(cur == nullptr)
        {
            return;
        }
        recursion(cur->left, vec);
        recursion(cur->right, vec);
        vec.push_back(cur->val);
    }

    vector<int> postorderTraversal(TreeNode* root) 
    {
        vector<int> result;
        recursion(root, result);
        return result;
    }
};